package com.lagou.rpc.provider.service;

import com.lagou.rpc.api.IOrderService;
import com.lagou.rpc.pojo.Order;
import com.lagou.rpc.provider.anno.RpcService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@RpcService
@Service
public class OrderServiceImpl implements IOrderService {
    private List<Order> orderList = new ArrayList<>();

    @Override
    public List<Order> getOrderByUserId(int uid) {
        if (orderList.size() == 0) {
            orderList.add(new Order(1, "牛奶", 1));
            orderList.add(new Order(2, "麦片", 1));
            orderList.add(new Order(3, "香蕉", 1));
            orderList.add(new Order(4, "果汁", 2));

        }

        List<Order> res = new ArrayList<>();
        for (Order order : orderList) {
            if (order.getUid() == uid) {
                res.add(order);
            }
        }

        return res;
    }
}
